package logic

import (
	"context"
	"os"

	"zlei/app/user/rpc/internal/svc"
	"zlei/app/user/rpc/protobuf"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserLogic {
	return &GetUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetUserLogic) GetUser(in *protobuf.IdRequest) (*protobuf.UserResponse, error) {
	name, _ := os.Hostname()
	if len(in.Id) >= 2 {
		name = "Unknown"
	}
	return &protobuf.UserResponse{
		Id:     in.GetId(),
		Name:   name,
		Gender: "男",
	}, nil
}
